package com.mapforge.map.tools.undo;

import java.util.List;
import java.util.Vector;

import javax.swing.ImageIcon;

public class CompositeUndoRedo extends UndoRedo {

	private List<UndoRedo> undoRedoList;

	public CompositeUndoRedo(ImageIcon icon, String description) {
		super(icon, description);
		undoRedoList = new Vector<UndoRedo>();
	}

	public synchronized void addEdit(UndoRedo edit) {
		undoRedoList.add(edit);
	}

	public synchronized void die() {
		for (int i = 0; i < undoRedoList.size(); i++) {
			undoRedoList.get(i).die();
		}
	}

	public synchronized void redo() {
		for (int i = 0; i < undoRedoList.size(); i++) {
			undoRedoList.get(i).redo();
		}
	}

	public synchronized void undo() {
		for (int i = 0; i < undoRedoList.size(); i++) {
			undoRedoList.get(i).undo();
		}
	}

}
